package com.ylkj.bus.dispatcher;


import com.ylkj.Application;
import com.ylkj.bus.MessageContent;
import com.ylkj.bus.dispatcher.handler.ReportContainerStreamHandler;
import com.ylkj.dao.RdsConfig;
import org.apache.flink.streaming.api.datastream.DataStream;

import java.util.Properties;

/**
 * @Author: wengzx
 * @Date: 2025/3/28
 * @Desc:
 */
public enum DispatcherHandler {
    //    容器状态上报
    REP_CON_STATUS {
        @Override
        protected IStreamHandler getHandler(Properties flinkProperties) {
            String tableName = flinkProperties.getProperty("reportContainer.rds.tableName");
            RdsConfig rdsConfig = Application.getRdsConfig(flinkProperties);
            return new ReportContainerStreamHandler(rdsConfig, tableName);
        }
    };
    protected abstract IStreamHandler getHandler(Properties flinkProperties);

    public void dispatch(DataStream<MessageContent> stream, Properties flinkProperties) {
        getHandler(flinkProperties).handle(stream);
    }

}
